package com.example.demo.concurrent.MyThreadPool2;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-03-27
 * Time: 18:51
 */
@Slf4j(topic = "c.TestDemo2")
public class TestDemo2 {

    public static void main(String[] args) throws Exception {
        ExecutorService service = Executors.newFixedThreadPool(2);

        Future<String> future = service.submit(() -> {
            log.debug("running");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "ok";
        });

        log.debug("{}",future.get());
    }

}
